/**
 * Mobile Responsive Optimization
 * 移动端响应式优化样式
 * 
 * @package WP Bootstrap Woo
 */

/* ==========================================================================
   移动端基础样式
   ========================================================================== */

/* 移动端视口设置 */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* 移动端基础重置 */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    body {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
    }
}

/* ==========================================================================
   移动端导航菜单
   ========================================================================== */

@media (max-width: 768px) {
    .navbar-collapse {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        background: #fff;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        z-index: 9999;
        overflow-y: auto;
    }
    
    .navbar-collapse.show {
        left: 0;
    }
    
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
        display: none;
    }
    
    .mobile-menu-overlay.show {
        display: block;
    }
    
    .navbar-nav {
        padding: 60px 20px 20px;
    }
    
    .navbar-nav .nav-item {
        margin-bottom: 0;
        border-bottom: 1px solid #f1f3f4;
    }
    
    .navbar-nav .nav-link {
        padding: 15px 0;
        font-size: 16px;
        color: #495057;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .navbar-nav .dropdown-menu {
        position: static;
        display: none;
        float: none;
        width: auto;
        margin-top: 0;
        background: #f8f9fa;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
    }
    
    .navbar-nav .dropdown-menu.show {
        display: block;
    }
    
    .navbar-nav .dropdown-item {
        padding: 12px 20px;
        color: #6c757d;
        font-size: 14px;
    }
    
    .mobile-menu-close {
        position: absolute;
        top: 15px;
        right: 20px;
        background: none;
        border: none;
        font-size: 24px;
        color: #495057;
        cursor: pointer;
    }
}

/* ==========================================================================
   移动端商店页面
   ========================================================================== */

@media (max-width: 768px) {
    .woocommerce ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
    
    .woocommerce ul.products li.product {
        margin: 0;
    }
    
    .woocommerce ul.products li.product .woocommerce-loop-product__title {
        font-size: 14px;
        padding: 10px 15px 5px;
        line-height: 1.3;
        -webkit-line-clamp: 3;
    }
    
    .woocommerce ul.products li.product .price {
        font-size: 16px;
        padding: 0 15px 10px;
    }
    
    .woocommerce ul.products li.product .add_to_cart_button {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    /* 商店筛选器 */
    .shop-filters {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #dee2e6;
        padding: 15px;
        z-index: 1000;
        display: flex;
        gap: 10px;
    }
    
    .shop-filters .filter-btn {
        flex: 1;
        padding: 12px 8px;
        font-size: 12px;
        text-align: center;
        border: 1px solid #dee2e6;
        background: #fff;
        border-radius: 6px;
        cursor: pointer;
    }
    
    .shop-filters .filter-btn.active {
        background: #007cba;
        color: #fff;
        border-color: #007cba;
    }
    
    /* 移动端侧边栏 */
    .shop-sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        height: 100vh;
        background: #fff;
        z-index: 9999;
        overflow-y: auto;
        transition: right 0.3s ease;
        padding: 60px 20px 20px;
    }
    
    .shop-sidebar.show {
        right: 0;
    }
    
    .shop-sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
        display: none;
    }
    
    .shop-sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 480px) {
    .woocommerce ul.products {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .woocommerce ul.products li.product {
        max-width: 100%;
    }
}

/* ==========================================================================
   移动端产品页面
   ========================================================================== */

@media (max-width: 768px) {
    .woocommerce div.product {
        display: block;
    }
    
    .woocommerce div.product div.images {
        margin-bottom: 20px;
        position: relative;
    }
    
    .woocommerce div.product .summary {
        padding-left: 0;
    }
    
    .woocommerce div.product .summary .entry-title {
        font-size: 22px;
        margin-bottom: 10px;
    }
    
    .woocommerce div.product .summary .price {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    /* 移动端产品图片滑块 */
    .product-gallery-mobile {
        position: relative;
        overflow: hidden;
        border-radius: 12px;
    }
    
    .product-gallery-slides {
        display: flex;
        transition: transform 0.3s ease;
    }
    
    .product-gallery-slide {
        min-width: 100%;
        aspect-ratio: 1;
    }
    
    .product-gallery-slide img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .product-gallery-indicators {
        position: absolute;
        bottom: 15px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 8px;
    }
    
    .product-gallery-indicator {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(255,255,255,0.5);
        cursor: pointer;
        transition: background 0.3s ease;
    }
    
    .product-gallery-indicator.active {
        background: #fff;
    }
    
    /* 移动端变体选择 */
    .variations_form .variations {
        margin-bottom: 20px;
    }
    
    .variations_form .variations tr {
        display: block;
        margin-bottom: 15px;
    }
    
    .variations_form .variations td {
        display: block;
        padding: 0;
    }
    
    .variations_form .variations .label {
        margin-bottom: 8px;
        font-weight: 600;
    }
    
    .variations_form .variations select {
        width: 100%;
        padding: 12px 15px;
        border: 2px solid #dee2e6;
        border-radius: 6px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 移动端数量选择 */
    .quantity {
        display: flex;
        align-items: center;
        margin-bottom: 20px;
    }
    
    .quantity .qty {
        width: 60px;
        text-align: center;
        margin: 0 10px;
        border: 2px solid #dee2e6;
        border-radius: 6px;
        padding: 10px 5px;
        font-size: 16px;
    }
    
    .qty-btn {
        width: 40px;
        height: 40px;
        border: 2px solid #dee2e6;
        background: #f8f9fa;
        border-radius: 6px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        font-weight: bold;
    }
    
    .qty-btn:hover {
        background: #007cba;
        color: #fff;
        border-color: #007cba;
    }
}

/* ==========================================================================
   移动端购物车页面
   ========================================================================== */

@media (max-width: 768px) {
    .woocommerce-cart table.cart {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .woocommerce-cart table.cart thead {
        display: none;
    }
    
    .woocommerce-cart table.cart tbody tr {
        display: block;
        background: #fff;
        margin-bottom: 15px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        overflow: hidden;
    }
    
    .woocommerce-cart table.cart tbody td {
        display: block;
        padding: 15px;
        border: none;
        text-align: left;
        position: relative;
    }
    
    .woocommerce-cart table.cart tbody td:before {
        content: attr(data-title) ': ';
        font-weight: 600;
        color: #495057;
        margin-right: 10px;
    }
    
    .woocommerce-cart table.cart .product-thumbnail {
        float: left;
        margin-right: 15px;
        width: 60px;
    }
    
    .woocommerce-cart table.cart .product-name {
        overflow: hidden;
    }
    
    .cart-collaterals {
        margin-top: 30px;
    }
    
    .cart_totals {
        padding: 20px;
    }
}

/* ==========================================================================
   移动端结账页面
   ========================================================================== */

@media (max-width: 768px) {
    .woocommerce-checkout .checkout-form {
        display: block;
    }
    
    .checkout-billing,
    .checkout-shipping {
        margin-bottom: 30px;
        padding: 20px;
    }
    
    .checkout-order-review {
        padding: 20px;
        position: static;
    }
    
    .woocommerce-checkout .form-row {
        margin-bottom: 15px;
    }
    
    .woocommerce-checkout .form-row-first,
    .woocommerce-checkout .form-row-last {
        width: 100%;
        margin-right: 0;
    }
    
    .woocommerce-checkout input,
    .woocommerce-checkout select,
    .woocommerce-checkout textarea {
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    #place_order {
        width: 100%;
        padding: 15px;
        font-size: 16px;
        margin-top: 20px;
    }
}

/* ==========================================================================
   移动端我的账户页面
   ========================================================================== */

@media (max-width: 768px) {
    .woocommerce-account .account-wrapper {
        display: block;
    }
    
    .woocommerce-account .woocommerce-MyAccount-navigation {
        margin-bottom: 20px;
        padding: 15px;
    }
    
    .woocommerce-account .woocommerce-MyAccount-navigation ul {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 10px;
    }
    
    .woocommerce-account .woocommerce-MyAccount-navigation ul li {
        flex: 0 0 auto;
        margin-right: 10px;
        margin-bottom: 0;
    }
    
    .woocommerce-account .woocommerce-MyAccount-navigation ul li a {
        padding: 10px 15px;
        font-size: 14px;
        border: 1px solid #dee2e6;
        border-radius: 20px;
        white-space: nowrap;
    }
    
    .woocommerce-account .woocommerce-MyAccount-content {
        padding: 20px;
    }
    
    /* 移动端订单表格 */
    .woocommerce-account .orders-table table {
        display: block;
        overflow-x: auto;
    }
    
    .woocommerce-account .orders-table thead {
        display: none;
    }
    
    .woocommerce-account .orders-table tbody tr {
        display: block;
        margin-bottom: 20px;
        background: #f8f9fa;
        border-radius: 8px;
        padding: 15px;
    }
    
    .woocommerce-account .orders-table tbody td {
        display: block;
        padding: 8px 0;
        border: none;
        text-align: left;
    }
    
    .woocommerce-account .orders-table tbody td:before {
        content: attr(data-title) ': ';
        font-weight: 600;
        color: #495057;
        margin-right: 10px;
    }
}

/* ==========================================================================
   移动端触摸优化
   ========================================================================== */

@media (max-width: 768px) {
    /* 增大点击区域 */
    .btn,
    .button,
    .add_to_cart_button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    /* 表单元素触摸优化 */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
        padding: 12px 15px;
    }
    
    /* 链接触摸区域 */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    /* 滑动手势支持 */
    .swipeable {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }
}

/* ==========================================================================
   移动端性能优化
   ========================================================================== */

@media (max-width: 768px) {
    /* 减少动画和过渡效果 */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }
    
    /* 图片懒加载样式 */
    img[data-src] {
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    img[data-src].loaded {
        opacity: 1;
    }
    
    /* 内容加载动画 */
    .loading-skeleton {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }
    
    @keyframes loading {
        0% {
            background-position: 200% 0;
        }
        100% {
            background-position: -200% 0;
        }
    }
}

/* ==========================================================================
   移动端字体和排版优化
   ========================================================================== */

@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    h1 {
        font-size: 24px;
        line-height: 1.3;
    }
    
    h2 {
        font-size: 20px;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 18px;
        line-height: 1.3;
    }
    
    h4 {
        font-size: 16px;
        line-height: 1.3;
    }
    
    h5 {
        font-size: 14px;
        line-height: 1.3;
    }
    
    h6 {
        font-size: 12px;
        line-height: 1.3;
    }
    
    p {
        margin-bottom: 15px;
        line-height: 1.6;
    }
}

/* ==========================================================================
   移动端状态栏和工具栏
   ========================================================================== */

@media (max-width: 768px) {
    /* 移动端顶部工具栏 */
    .mobile-toolbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: #fff;
        border-bottom: 1px solid #dee2e6;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 15px;
    }
    
    .mobile-toolbar .logo {
        height: 40px;
    }
    
    .mobile-toolbar .toolbar-actions {
        display: flex;
        gap: 15px;
    }
    
    .mobile-toolbar .toolbar-btn {
        width: 40px;
        height: 40px;
        background: none;
        border: none;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        color: #495057;
        cursor: pointer;
        position: relative;
    }
    
    .mobile-toolbar .toolbar-btn:hover {
        background: #f8f9fa;
    }
    
    .mobile-toolbar .cart-count,
    .mobile-toolbar .wishlist-count {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #dc3545;
        color: #fff;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        font-size: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
    }
    
    /* 为固定顶部工具栏添加内容间距 */
    body.has-mobile-toolbar {
        padding-top: 60px;
    }
}

/* ==========================================================================
   移动端底部导航
   ========================================================================== */

@media (max-width: 768px) {
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: #fff;
        border-top: 1px solid #dee2e6;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding: 0 10px;
    }
    
    .mobile-bottom-nav .nav-item {
        flex: 1;
        text-align: center;
        text-decoration: none;
        color: #6c757d;
        padding: 8px 5px;
        border-radius: 8px;
        transition: all 0.3s ease;
    }
    
    .mobile-bottom-nav .nav-item.active,
    .mobile-bottom-nav .nav-item:hover {
        color: #007cba;
        background: rgba(0, 124, 186, 0.1);
    }
    
    .mobile-bottom-nav .nav-icon {
        font-size: 20px;
        margin-bottom: 4px;
        display: block;
    }
    
    .mobile-bottom-nav .nav-label {
        font-size: 10px;
        font-weight: 500;
        display: block;
    }
    
    /* 为固定底部导航添加内容间距 */
    body.has-mobile-bottom-nav {
        padding-bottom: 60px;
    }
}